#include "motor_inf.h"
#include "filter.h"
#include "adc_fun.h"
#include "math.h"
motor_inf_t motor_inf;

float adc_to_currunt(float adc){
	float y = 0;
	y = adc*3.3F/4096.F*3.636F;
	return y;
}
void get_m_inf(float theta){
	
	motor_inf.motor_iabc_t._ia = adc_to_currunt(F_adc_data._FA_adc);
	motor_inf.motor_iabc_t._ib = adc_to_currunt(F_adc_data._FB_adc);
	motor_inf.motor_iabc_t._ic = adc_to_currunt(F_adc_data._FC_adc);
//	motor_inf.motor_iabc_t._ia = iir_filter_2(adc_to_currunt(F_adc_data._FA_adc),ADC_ACH);
//	motor_inf.motor_iabc_t._ib = iir_filter_2(adc_to_currunt(F_adc_data._FB_adc),ADC_BCH);
//	motor_inf.motor_iabc_t._ic = iir_filter_2(adc_to_currunt(F_adc_data._FC_adc),ADC_CCH);
	
//	
//	float ialpha,ibeta = 0;
//	float ia,ib,ic=0;
//	ia = motor_inf.motor_iabc_t._ia;
//	ib = motor_inf.motor_iabc_t._ib;
//	ic = motor_inf.motor_iabc_t._ic;
//	ialpha = ia*2.f/3.f-(ib+ic)/3.f;
//	ibeta = (ib-ic)*sqrt(3.f)/3.f;//clark

//	motor_inf.motor_iab_t._ial = ialpha;
//	motor_inf.motor_iab_t._ibe = ibeta;
//	
//	float id,iq=0;
//	id = ialpha *cos(theta)+ibeta*sin(theta);
//	iq = -ialpha * sin(theta)+ibeta *cos(theta);//park
//	
//	motor_inf.motor_idq_t._id = id;
//	motor_inf.motor_idq_t._iq = iq;
}





